/*
	模块的基础配置
 */
var echarts = require('echarts');
import moduledata from '@/store/module/moduledata'

export default{
	Jichuzhuzhuangtu(params){
		var moduledatas = params.moduledatas;
		var series = [];
		for (let i = 0; i < moduledatas.y.length; i++) {
			let style = moduledatas.style.y[i]?moduledatas.style.y[i]:moduledata.state.jichuzhuzhuangtu.style.y[0];
			let label = moduledatas.label[i]?moduledatas.label[i]:["标签"];
			series[i]={
                barWidth:style.barWidth,
                name: label,
                type: 'bar',
                data: moduledatas.y[i],
                itemStyle:{
                  normal: {
                  	  borderWidth:style.borderWidth||0,
                      borderColor:style.borderColor||"#000",
                      barBorderRadius: 0,
                      //每个柱子的颜色即为colorList数组里的每一项，如果柱子数目多于colorList的长度，则柱子颜色循环使用该数组
                      color: function (param) {
                          var colorList = style.color;
                          var index = param.dataIndex;
                          if (param.dataIndex >= colorList.length) {
                              index = param.dataIndex - colorList.length;
                          }
                          if (!colorList[index]) {
                          	colorList[index] = ['#10B9F8', '#10B9F8'];
                          }
                          return new echarts.graphic.LinearGradient(0, 0, 0, 1,
                              [{
                                  offset: 0,
                                  color: colorList[index][1]
                              },
                              {
                                  offset: 1,
                                  color: colorList[index][0]
                              }
                          ]);
                      },
                      label:{
                        show: style.label.show, //开启显示
                        position:style.label.position, //在上方显示
                        textStyle: { //数值样式
                          color:  style.label.color,
                          fontSize: style.label.fontSize
                        }
                      }
                  }, //normal_end
                }
            }
		}
		var data = {
			      tooltip:{},
            xAxis: {
                  data: moduledatas.x,
                  axisLine:params.xAxis.axisLine,
                  axisLabel: params.xAxis.axisLabel
            },
            yAxis: {
            	axisLine:params.yAxis.axisLine,
                axisLabel:{
                   show: true,
                    textStyle: {
                      color: params.yAxis.axisLabel.color,  //更改坐标轴文字颜色
                      fontSize : params.yAxis.axisLabel.fontSize     //更改坐标轴文字大小
                    },
                    formatter: function (value, index) {
		                if (value >= 10000 && value < 10000000) {
		                    value = value / 10000 + "w";
		                } else if (value >= 10000000) {
		                    value = value / 10000000 + "kw";
		                } else if (value >= 1000 && value < 10000) {
		                    value = value / 1000 + "k";
		                }
		                return value;
		            }
                 },
                 splitLine:params.yAxis.splitLine,
              },
            series: series //series_end
        }
        return data;
	},
	Caisezhuzhuangtu(params){
		var moduledatas = params.moduledatas;
		var series = [];
		for (let i = 0; i < moduledatas.y.length; i++) {
      
			let style = moduledatas.style.y[i]?moduledatas.style.y[i]:moduledata.state.caisezhuzhuangtu.style.y[0];
			let label = moduledatas.label[i]?moduledatas.label[i]:"标签";
			series[i]={
                barWidth:style.barWidth,
                name: label,
                type: 'bar',
                data: moduledatas.y[i],
                itemStyle:{
                  normal: {
                  	  borderWidth:style.borderWidth||0,
                      borderColor:style.borderColor||"#000",
                      barBorderRadius: 0,
                      //每个柱子的颜色即为colorList数组里的每一项，如果柱子数目多于colorList的长度，则柱子颜色循环使用该数组
                      color: function (param) {
                          var colorList =style.color;
                          var index = param.dataIndex;
                          if (param.dataIndex >= colorList.length) {
                              index = param.dataIndex - colorList.length;
                          }
                          if (!colorList[index]) {
                          	colorList[index] = ['#10B9F8', '#10B9F8'];
                          }
                          return new echarts.graphic.LinearGradient(0, 0, 0, 1,
                              [{
                                      offset: 0,
                                      color: colorList[index][1]
                                  },
                                  {
                                      offset: 1,
                                      color: colorList[index][0]
                                  }
                              ]);
                      },
                      label:{
                        show: style.label.show, //开启显示
                        position: style.label.position, //在上方显示
                        textStyle: { //数值样式
                          color:  style.label.color,
                          fontSize: style.label.fontSize
                        }
                      }
                  }, //normal_end
                }
            }
		}
		var data = {
			tooltip:{},
            xAxis: {
                  data: moduledatas.x,
                  axisLine:params.xAxis.axisLine,
                  axisLabel: params.xAxis.axisLabel
            },
            yAxis: {
            	axisLine:params.yAxis.axisLine,
                axisLabel:{
                   show: true,
                    textStyle: {
                      color: params.yAxis.axisLabel.color,  //更改坐标轴文字颜色
                      fontSize : params.yAxis.axisLabel.fontSize     //更改坐标轴文字大小
                    },
                    formatter: function (value, index) {
		                if (value >= 10000 && value < 10000000) {
		                    value = value / 10000 + "w";
		                } else if (value >= 10000000) {
		                    value = value / 10000000 + "kw";
		                } else if (value >= 1000 && value < 10000) {
		                    value = value / 1000 + "k";
		                }
		                return value;
		            }
                },
                 splitLine:params.yAxis.splitLine,
              },
            series: series //series_end
        }
        return data;
	},
  Jizuobiaozhuzhuangtu(params){
    var moduledatas = params.moduledatas;
    var series = [];
    // 获取最大值，设置极坐标最大值
    var arrayNum =moduledatas.y.join(",").split(",");
    var max = Math.max.apply(null,arrayNum);
    params.angleAxis.max = max+10;
    for (let i = 0; i < moduledatas.y.length; i++) {
      let style = moduledatas.style.y[i]?moduledatas.style.y[i]:moduledata.state.jizuobiaozhuzhuangtu.style.y[0];
      let label = moduledatas.label[i]?moduledatas.label[i]:"标签";
      series[i]={
        name: label,
        type: 'bar',
        coordinateSystem: 'polar',
        data: moduledatas.y[i],
        barWidth:style.barWidth,
        itemStyle:{
          normal: {
              borderWidth:style.borderWidth||0,
              borderColor:style.borderColor||"#000",
              //每个柱子的颜色即为colorList数组里的每一项，如果柱子数目多于colorList的长度，则柱子颜色循环使用该数组
              color: function (param) {
                  var colorList =style.color;
                  var index = param.dataIndex;
                  if (param.dataIndex >= colorList.length) {
                      index = param.dataIndex - colorList.length;
                  }
                  if (!colorList[index]) {
                    colorList[index] = ['#10B9F8', '#10B9F8'];
                  }
                  return new echarts.graphic.LinearGradient(0, 0, 0, 1,
                      [{
                              offset: 0,
                              color: colorList[index][1]
                          },
                          {
                              offset: 1,
                              color: colorList[index][0]
                          }
                      ]);
              },
              label:{
                show: style.label.show, //开启显示
                position: style.label.position, //在上方显示
                textStyle: { //数值样式
                  color:  style.label.color,
                  fontSize: style.label.fontSize
                }
              }
          }, //normal_end
        }
      }
    }
    var data = {
        tooltip:{},
        angleAxis: params.angleAxis,
        radiusAxis: {
            type: 'category',
            data: moduledatas.x,
            z: 1,
            nameTextStyle:params.radiusAxis.nameTextStyle,
            axisLine:params.radiusAxis.axisLine
        },
        polar: {},
        legend: {
            show: true,
            data: moduledatas.label,
            textStyle:{
              color:"#fff"
            }
        },
        series: series //series_end   
    }
    return data;
  },
  Duidiezhuzhuangtu(params){
    var moduledatas = params.moduledatas;
    var series = [];
    for (let i = 0; i < moduledatas.y.length; i++) {
      
      let style = moduledatas.style.y[i]?moduledatas.style.y[i]:moduledata.state.duidiezhuzhuangtu.style.y[0];
      let label = moduledatas.label[i]?moduledatas.label[i]:"标签";
      series[i]={
                barWidth:style.barWidth,
                name: label,
                type: 'bar',
                stack:"堆叠",
                data: moduledatas.y[i],
                itemStyle:{
                  normal: {
                      borderWidth:style.borderWidth||0,
                      borderColor:style.borderColor||"#000",
                      barBorderRadius: 0,
                      //每个柱子的颜色即为colorList数组里的每一项，如果柱子数目多于colorList的长度，则柱子颜色循环使用该数组
                      color: function (param) {
                          var colorList =style.color;
                          var index = param.dataIndex;
                          if (param.dataIndex >= colorList.length) {
                              index = param.dataIndex - colorList.length;
                          }
                          if (!colorList[index]) {
                            colorList[index] = ['#10B9F8', '#10B9F8'];
                          }
                          return new echarts.graphic.LinearGradient(0, 0, 0, 1,
                              [{
                                      offset: 0,
                                      color: colorList[index][1]
                                  },
                                  {
                                      offset: 1,
                                      color: colorList[index][0]
                                  }
                              ]);
                      },
                      label:{
                        show: style.label.show, //开启显示
                        position: style.label.position, //在上方显示
                        textStyle: { //数值样式
                          color:  style.label.color,
                          fontSize: style.label.fontSize
                        }
                      }
                  }, //normal_end
                }
            }
    }
    var data = {
      tooltip:{},
            xAxis: {
                  data: moduledatas.x,
                  axisLine:params.xAxis.axisLine,
                  axisLabel: params.xAxis.axisLabel
            },
            yAxis: {
              axisLine:params.yAxis.axisLine,
                axisLabel:{
                   show: true,
                    textStyle: {
                      color: params.yAxis.axisLabel.color,  //更改坐标轴文字颜色
                      fontSize : params.yAxis.axisLabel.fontSize     //更改坐标轴文字大小
                    },
                    formatter: function (value, index) {
                    if (value >= 10000 && value < 10000000) {
                        value = value / 10000 + "w";
                    } else if (value >= 10000000) {
                        value = value / 10000000 + "kw";
                    } else if (value >= 1000 && value < 10000) {
                        value = value / 1000 + "k";
                    }
                    return value;
                }
                },
                 splitLine:params.yAxis.splitLine,
              },
            series: series //series_end
        }
        return data;
  },
  Jiaocuozhengfuzhoubiaoqiantu(params){
    var moduledatas = params.moduledatas;
    var series = [];
    for (let i = 0; i < moduledatas.y.length; i++) {
      let style = moduledatas.style.y[i]?moduledatas.style.y[i]:moduledata.state.jiaocuozhengfuzhoubiaoqiantu.style.y[0];
      let label = moduledatas.label[i]?moduledatas.label[i]:"标签";
      series[i]={
                // barWidth:style.barWidth,
                name: label,
                type: 'bar',
                // stack:"堆叠",
                data: moduledatas.y[i],
                itemStyle:{
                  normal: {
                      borderWidth:style.borderWidth||0,
                      borderColor:style.borderColor||"#000",
                      barBorderRadius: 0,
                      //每个柱子的颜色即为colorList数组里的每一项，如果柱子数目多于colorList的长度，则柱子颜色循环使用该数组
                      color: function (param) {
                          var colorList =style.color;
                          var index = param.dataIndex;
                          if (param.dataIndex >= colorList.length) {
                              index = param.dataIndex - colorList.length;
                          }
                          if (!colorList[index]) {
                            colorList[index] = ['#10B9F8', '#10B9F8'];
                          }
                          return new echarts.graphic.LinearGradient(0, 0, 0, 1,
                              [{
                                      offset: 0,
                                      color: colorList[index][1]
                                  },
                                  {
                                      offset: 1,
                                      color: colorList[index][0]
                                  }
                              ]);
                      },
                      label:{
                        show: style.label.show, //开启显示
                        position: style.label.position, //在上方显示
                        textStyle: { //数值样式
                          color:  style.label.color,
                          fontSize: style.label.fontSize
                        }
                      }
                  }, //normal_end
                }
            }
    }
    var data = {
      tooltip:{},
            xAxis: {
                  type:"value",
                  // data: moduledatas.x,
                  position: 'top',
                  axisLine:params.xAxis.axisLine,
                  axisLabel: params.xAxis.axisLabel,
                  splitLine:params.xAxis.splitLine
            },
            yAxis: {
                type: 'category',
                axisLine:params.yAxis.axisLine,
                axisTick: params.yAxis.axisTick,
                axisLabel:{
                   show: false,
                    textStyle: {
                      color: params.yAxis.axisLabel.color,  //更改坐标轴文字颜色
                      fontSize : params.yAxis.axisLabel.fontSize     //更改坐标轴文字大小
                    },
                    formatter: function (value, index) {
                        if (value >= 10000 && value < 10000000) {
                            value = value / 10000 + "w";
                        } else if (value >= 10000000) {
                            value = value / 10000000 + "kw";
                        } else if (value >= 1000 && value < 10000) {
                            value = value / 1000 + "k";
                        }
                        return value;
                    }
                },
                data:moduledatas.x,
                splitLine:params.yAxis.splitLine,
            },
            series: series //series_end
        }
        return data;
  },
	Meiguitu(params){
		var moduledatas = params.moduledatas;
		var series = [];
		var y = [];

		for (let i = 0; i < moduledatas.x.length; i++) {
			let color = params.style.color[i] || moduledata.state.meiguitu.style.color[0];
			y[i]={
				value:moduledatas.y[i]||0, 
				name:moduledatas.x[i],
				itemStyle:{
					borderColor:color[2],
                    borderWidth:color[3],
				},
			}
		}
		series[0]={
            name:params.label,
            type:'pie',
            radius : params.style.radio,
            center : ['50%', '50%'],
            roseType : 'radius',
            label:{
              normal: {
                  show: true,
                  position: 'outside',
                  formatter: '{\d}%',
                  color:"#fff"
                },
                emphasis: {
                    show: true
                }
            },
            lableLine: {
                normal: {
                    show: true
                },
                emphasis: {
                    show: true
                }
            },
            itemStyle:{
              normal: {
                color: function (param) {
                  var colorList = params.style.color;
                  var index = param.dataIndex;
                  if (param.dataIndex >= colorList.length) {
                      index = param.dataIndex - colorList.length;
                  }
                  if (!colorList[index]) {
                  	colorList[index] = ['#10B9F8', '#10B9F8'];
                  }
                  return new echarts.graphic.LinearGradient(0, 0, 0, 1,
                      [{
                          offset: 0,
                          color: colorList[index][1]
                      },
                      {
                          offset: 1,
                          color: colorList[index][0]
                      }
                  ]);
                }
              }
            },
            data:y
    }
		var data = {
			tooltip:{},
			legend: {
			  show:moduledatas.legend.show,
              orient: moduledatas.legend.orient,  //垂直显示
              circle: moduledatas.legend.circle,
              x:moduledatas.legend.x,
              y:moduledatas.legend.y,
              align: moduledatas.legend.align,
              itemWidth:moduledatas.legend.itemWidth,
              itemHeight:moduledatas.legend.itemHeight,
              itemGap: moduledatas.legend.itemGap,
              textStyle:moduledatas.legend.textStyle,
              data:moduledatas.x
            },
            series: series //series_end
        }
        return data;
	},
  Qiantaobingtu(params){
    var moduledatas = params.moduledatas;
    var series = [];
    for (let i = 0; i < moduledatas.data.length; i++) {
      let label = moduledatas.label[i]?moduledatas.label[i]:"标签";
      let color = params.style[i]?params.style[i].color:moduledata.state.qiantaobingtu.style[0].color;
      let radio = params.style[i]?params.style[i].radio:moduledata.state.qiantaobingtu.style[0].radio;
      var y = [];
      for (var j = 0; j < moduledatas.data[i].length; j++) {
        y[j]={
          value:moduledatas.data[i][j].value||0, 
          name:moduledatas.data[i][j].name||'值',
          itemStyle:{
            borderColor:color[j]?color[j][2]:moduledata.state.qiantaobingtu.style[0].color[0][2],
            borderWidth:color[j]?color[j][3]:moduledata.state.qiantaobingtu.style[0].color[0][3],
          }
        }
      }
      series[i]={
          name:label,
          type:'pie',
          // radius : params.style.radio,
          radius: [radio[0]+"%", radio[1]+"%"],
          label:{
            position: 'inner',
            normal: {
              show: true,
              position: i==0?'inner':'outside',
              formatter: '{\d}%',
              color:"#fff"
            },
            emphasis: {
                show: true
            }
          },
          lableLine: {
              normal: {
                  show: true
              },
              emphasis: {
                  show: true
              }
          },
          itemStyle:{
            normal: {
              color: function (param) {
                var colorList = color;
                var index = param.dataIndex;
                if (param.dataIndex >= colorList.length) {
                    index = param.dataIndex - colorList.length;
                }
                if (!colorList[index]) {
                  colorList[index] = ['#10B9F8', '#10B9F8'];
                }
                return new echarts.graphic.LinearGradient(0, 0, 0, 1,
                    [{
                        offset: 0,
                        color: colorList[index][1]
                    },
                    {
                        offset: 1,
                        color: colorList[index][0]
                    }
                ]);
              }
            }
          },
          data:y
      }
    }
    
    var data = {
      tooltip:{},
      legend: {
          show:moduledatas.legend.show,
          orient: moduledatas.legend.orient,  //垂直显示
          circle: moduledatas.legend.circle,
          x:moduledatas.legend.x,
          y:moduledatas.legend.y,
          align: moduledatas.legend.align,
          itemWidth:moduledatas.legend.itemWidth,
          itemHeight:moduledatas.legend.itemHeight,
          itemGap: moduledatas.legend.itemGap,
          textStyle:moduledatas.legend.textStyle,
          data:moduledatas.x
        },
        series: series //series_end
      }
      return data;
  },
	Tiaoxingtu(params){
		var moduledatas = params.moduledatas;
		var series = [];
		for (let i = 0; i < moduledatas.y.length; i++) {
			let style = moduledatas.style.y[i]?moduledatas.style.y[i]:moduledata.state.tiaoxingtu.style.y[0];
			let label = moduledatas.label[i]?moduledatas.label[i]:["标签"];
			series[i]={
                name:moduledatas.label[i]||"",
                type:'line',
                lineStyle:style.lineStyle,
                smooth: true,
                symbolSize:style.symbolSize,
                itemStyle:style.itemStyle,
                areaStyle:style.areaStyle,
                data:moduledatas.y[i]
            }
		}
		var data ={
            tooltip : {
                trigger: 'axis',
                axisPointer: {
                    type: 'cross',
                    label: {
                        backgroundColor: '#6a7985'
                    }
                }
            },
            toolbox: {
            	feature:{
            		saveImage:{}
            	}
            },
            xAxis : [
                {
                    type : 'category',
                    boundaryGap : false,
                    data : moduledatas.x,
                    axisLine:params.xAxis.axisLine,
                    axisLabel: params.xAxis.axisLabel
                }
            ],
            yAxis : [
                {
                    type : 'value',
                    axisLine:params.yAxis.axisLine,
                    axisLabel:{
                      color:params.yAxis.axisLabel.color,
                      fontSize:params.yAxis.axisLabel.fontSize,
                      formatter:function (value, index) {
                          if (value >= 10000 && value < 10000000) {
                              value = value / 10000 + "w";
                          } else if (value >= 10000000) {
                              value = value / 10000000 + "kw";
                          } else if (value >= 1000 && value < 10000) {
                              value = value / 1000 + "k";
                          }
                          return value;
                        }
                    },
                    splitLine:params.yAxis.splitLine
                }
            ],
            series : series
        }
        return data;
	},
	Jinduhuantu(params){
		var data = {
            series: [{
				name: 'jichuhuantu',
				type: 'pie',
				radius: [params.radius[0]+'%', params.radius[1]+'%'],
				avoidLabelOverlap: false,
				hoverAnimation:false,
				color:[params.color[0],params.color[1]],
				label:{
					normal: {
						show: true,
						position: 'center',
						formatter: '{label|'+params.value+'%}'+ '\n\r' + '{active|'+params.name+'}',
						rich: {
						    label:params.style.label,
						    active:params.style.active,
						}
					}
				},
				data: [{
				  value: params.value,
				  name:params.name,
				  label:{
				      normal:{
				          show:true
				      }
				  },
				  itemStyle:params.style.itemStyle
				},{
					value:100-params.value,
					name:"ss",
					label:{
						normal:{
						    show:true
						}
					}
				}]
            }]
		}
		return data;
	},
	Ditu(params){
		if (!params) {
			return ""
		}
		var data = params.data;
		var geoCoordMap = params.geoCoordMap;
		var convertData = this.convertDituData;
		var option ={
		    title : {
		    },
		    tooltip: {
          show:true,
          trigger: 'item',
          confine: false,
          formatter: (p)=>{
              const dataCon = p.data;
              const txtCon =dataCon.name+'<br>值:'+dataCon.value[2];
              return txtCon;
          }
        },
		    legend: {
		        left: 'left',
		        data: ['强', '中', '弱'],
		        textStyle: {
		            color: '#ccc'
		        }
		    },
		    backgroundColor: params.style.backgroundColor||"rgba(0,0,0,0)",
		    geo: {
		        map: 'china',
		        show: true,
		        roam: false,
            zlevel:2,
		        label: {
		            emphasis: {
		                show: false
		            }
		        },
		        itemStyle: {
		            normal: {
		                areaColor: params.style.map.itemStyle.normal.areaColor||"rgba(0,0,0,0)",
                    borderColor: params.style.map.itemStyle.normal.borderColor||'rgba(0,0,0,0)',
                    shadowColor: '#ffffff',
                    shadowBlur: 0
		            }
		        }
		    },
		    series: [
		        // {
		        //     type: 'map',
		        //     map: 'china',
		        //     geoIndex: 1,
		        //     aspectScale: 0.75, //长宽比
		        //     showLegendSymbol: true, // 存在legend时显示
		        //     label: {
		        //         normal: {
		        //             show: false,
		        //         },
		        //         emphasis: {
		        //             show: false,
		        //             textStyle: {
		        //                 color: '#fff'
		        //             }
		        //         }
		        //     },
		        //     show: false,
		        //     itemStyle: params.style.map.itemStyle,
		        //     data:[
		        //         // {name: '北京',value: 21300 }
		        //     ]
		        // },
		        {
		            name: '城市',
		            type: 'scatter',
		            coordinateSystem: 'geo',
                zlevel:3,
		            data: convertData(data,geoCoordMap),
		            symbolSize: function (val) {
		                return val[2] / 20;
		            },
		            label: {
		                normal: {
		                    formatter: '{b}',
		                    position: 'right',
		                    show: false
		                },
		                emphasis: {
		                    show: true
		                }
		            },
		            itemStyle: params.style.scatter.itemStyle
		        },
		        {
		            name: 'TOP',
		            type: 'effectScatter',
		            coordinateSystem: 'geo',
		            data: convertData(data.sort(function (a, b) {
		                return b.value - a.value;
		            }).slice(0, 6),geoCoordMap),
		            symbolSize: function (val) {
		                return val[2] / 20;
		            },
                zlevel:3,
		            showEffectOn: 'render',
		            rippleEffect: {
		                brushType: 'stroke'
		            },
		            hoverAnimation: true,
		            label: params.style.effectScatter.label,
		            itemStyle: params.style.effectScatter.itemStyle,
		        }
		    ]
		}
		return option;
	},
  // 首页自己使用
  DituHome(params){
    if (!params) {
      return ""
    }
    var data = params.data;
    var geoCoordMap = params.geoCoordMap;
    var convertData = this.convertDituData;
    var option ={
        title : {
        },
        tooltip: {
          show:true,
          trigger: 'item',
          confine: false,
          formatter: (p)=>{
              const dataCon = p.data;
              const txtCon =dataCon.name+'<br>值:'+dataCon.value[2];
              return txtCon;
          }
        },
        legend: {
            left: 'left',
            data: ['强', '中', '弱'],
            textStyle: {
                color: '#ccc'
            }
        },
        backgroundColor: params.style.backgroundColor||"rgba(0,0,0,0)",
        geo: {
            map: 'china',
            show: true,
            roam: true,
            zlevel:2,
            label: {
                emphasis: {
                    show: false
                }
            },
            itemStyle: {
                normal: {
                    areaColor: params.style.map.itemStyle.normal.areaColor||"rgba(0,0,0,0)",
                    borderColor: params.style.map.itemStyle.normal.borderColor||'rgba(0,0,0,0)',
                    shadowColor: '#ffffff',
                    shadowBlur: 0
                }
            }
        },
        series: [
            // {
            //     type: 'map',
            //     map: 'china',
            //     geoIndex: 1,
            //     aspectScale: 0.75, //长宽比
            //     showLegendSymbol: true, // 存在legend时显示
            //     label: {
            //         normal: {
            //             show: false,
            //         },
            //         emphasis: {
            //             show: false,
            //             textStyle: {
            //                 color: '#fff'
            //             }
            //         }
            //     },
            //     show: false,
            //     itemStyle: params.style.map.itemStyle,
            //     data:[
            //         // {name: '北京',value: 21300 }
            //     ]
            // },
            {
                name: '城市',
                type: 'scatter',
                coordinateSystem: 'geo',
                zlevel:3,
                data: convertData(data,geoCoordMap),
                symbolSize: function (val) {
                    return val[2] / 20;
                },
                label: {
                    normal: {
                        formatter: '{b}',
                        position: 'right',
                        show: false
                    },
                    emphasis: {
                        show: true
                    }
                },
                itemStyle: params.style.scatter.itemStyle
            },
            {
                name: 'TOP',
                type: 'effectScatter',
                coordinateSystem: 'geo',
                data: convertData(data.sort(function (a, b) {
                    return b.value - a.value;
                }).slice(0, 6),geoCoordMap),
                symbolSize: function (val) {
                    return val[2] / 20;
                },
                zlevel:3,
                showEffectOn: 'render',
                rippleEffect: {
                    brushType: 'stroke'
                },
                hoverAnimation: true,
                label: params.style.effectScatter.label,
                itemStyle: params.style.effectScatter.itemStyle,
            }
        ]
    }
    return option;
  },
	convertDituData(data,geoCoordMap) {
	    var res = [];
	    for (var i = 0; i < data.length; i++) {
	        var geoCoord = geoCoordMap[data[i].name];
	        if (geoCoord) {
	            res.push({
	                name: data[i].name,
	                value: geoCoord.concat(data[i].value)
	            });
	        }
	    }
	    return res;
	},
  // 根据当前时间获取出当前月份的所有天数
  getVirtulData(month) {
    var time = new Date(month);
    var year = time.getFullYear();
    var month =
      time.getMonth() + 1 < 10
        ? "0" + (time.getMonth() + 1)
        : time.getMonth() + 1;
    var startTime = year + "-" + month + "-01"; //先获取到当前时间的月份第一天
    var endTime =
      year +
      "-" +
      (time.getMonth() + 2 < 10
        ? "0" + (time.getMonth() + 2)
        : time.getMonth() + 2) +
      "-01"; //当前月份的下个月的第一天
    var date = +echarts.number.parseDate(startTime);
    var end = +echarts.number.parseDate(endTime);
    var dayTime = 3600 * 24 * 1000;
    var data = [];
    for (var time = date; time < end; time += dayTime) {
      var str = 0;
      data.push([echarts.format.formatTime("yyyy-MM-dd", time), str]);
      str++;
    }
    return data;
  },
  // 日历图生成每天对应的饼图
  getPieSeries(params, chart) {
    var x = params.x;
    var y = params.y;
    var colorArr = [];
    params.style.dataColor.map(item => {
      colorArr.push(item.color||"#1e4eff");
    });
    var scatterData = this.getVirtulData(params.month);
    return echarts.util.map(scatterData, (item, index) => {
      var arr = [];
      x.map((str, num) => {
        var obj = {
          name: str,
          value: y[index][num]
        };
        arr.push(obj);
      });

      var center = chart.convertToPixel("calendar", item);
      return {
        id: index + "pie",
        type: "pie",
        color: colorArr,
        center: center,
        label: {
          normal: {
            formatter: "{c}",
            position: "inside"
          }
        },
        radius: params.cellSize / 2 - 5,
        data: arr
      };
    });
  },
  // 生成日历图
  rilitu(params) {
    var scatterData = this.getVirtulData(params.month);
    var option = {
      tooltip: {},
      title: {
        // text: params.month + "月份数据",
        // left: "center",
        // textStyle: {
        //   color: "#fff"
        // },
        // top: 10
      },
      legend: {
        data: params.x,
        bottom: 20,
        textStyle: {
          color: "#fff"
        },
        show:params.legend.show
      },
      calendar: {
        top: "middle",
        left: "center",
        orient: "vertical",
        cellSize: params.cellSize,
        yearLabel: {
          show: false
        },
        monthLabel: {
          show: false
        },
        dayLabel: {
          margin: 20,
          firstDay: 1,
          nameMap: params.nameMap,
          color: params.style.weekColor
        },
        range: params.month,
        itemStyle:{
          color:params.style.bgColor,
          borderColor:params.style.calendarBorderColor
        }
      },
      series: [
        {
          id: "label",
          type: "scatter",
          coordinateSystem: "calendar",
          symbolSize: 1,
          label: {
            normal: {
              show: true,
              formatter: params => {
                return echarts.format.formatTime("dd", params.value[0]);
              },
              offset: [-params.cellSize / 2 + 10, -params.cellSize / 2 + 10],
              textStyle: {
                color: params.style.dayColor,
                fontSize: 12
              }
            }
          },
          data: scatterData
        }
      ]
    };

    return option;
  },
  Duoyzhouzhuzhuangtu(params){
      var moduledatas = params.moduledatas;
      var series = [];
      for (let i = 0; i < moduledatas.y.length; i++) {
        let style = moduledatas.style.y[i]?moduledatas.style.y[i]:moduledata.state.duoyzhouzhuzhuangtu.style.y[0];
        let label = moduledatas.label[i]?moduledatas.label[i]:"标签";
        series[i]= (i===1)? {
            barWidth:style.barWidth,
            name:moduledatas.label[i]||"",
            type: 'bar',
            yAxisIndex: 1,
            data: moduledatas.y[i],
            itemStyle:{
              normal: {
                  borderWidth:style.borderWidth||0,
                  borderColor:style.borderColor||"#000",
                  barBorderRadius: 0,
                  //每个柱子的颜色即为colorList数组里的每一项，如果柱子数目多于colorList的长度，则柱子颜色循环使用该数组
                  color: function (param) {
                      var colorList =style.color;
                      var index = param.dataIndex;
                      if (param.dataIndex >= colorList.length) {
                          index = param.dataIndex - colorList.length;
                      }
                      if (!colorList[index]) {
                        colorList[index] = ['#10B9F8', '#10B9F8'];
                      }
                      return new echarts.graphic.LinearGradient(0, 0, 0, 1,
                          [{
                                  offset: 0,
                                  color: colorList[index][1]
                              },
                              {
                                  offset: 1,
                                  color: colorList[index][0]
                              }
                          ]);
                  },
                  label:{
                    show: style.label.show, //开启显示
                    position: style.label.position, //在上方显示
                    textStyle: { //数值样式
                      color:  style.label.color,
                      fontSize: style.label.fontSize
                    }
                  }
              }, //normal_end
            }
        }:{
            name:moduledatas.label[i]||"",
            type:'line',
            lineStyle:style.lineStyle,
            yAxisIndex: 0,
            smooth: true,
            symbolSize:style.symbolSize,
            itemStyle:style.itemStyle,
            areaStyle:style.areaStyle,
            data:moduledatas.y[i]
        }
      }
      var max0 = Math.max.apply(null,moduledatas.y[0]);
      var max1 = Math.max.apply(null,moduledatas.y[1]);
      var data = {
          tooltip:{
          },
          xAxis: [{
                type: 'category',
                data: moduledatas.x,
                axisLine:params.xAxis.axisLine,
                axisLabel: params.xAxis.axisLabel
          }],
          yAxis: [{
              type: 'value',
              name: moduledatas.label[0],
              min:0,
              max:max0,
              axisLine:params.yAxis.axisLine,
              axisLabel:{
                 show: true,
                  textStyle: {
                    color: params.yAxis.axisLabel.color,  //更改坐标轴文字颜色
                    fontSize : params.yAxis.axisLabel.fontSize     //更改坐标轴文字大小
                  },
                  formatter: function (value, index) {
                      if (value >= 10000 && value < 10000000) {
                          value = value / 10000 + "w";
                      } else if (value >= 10000000) {
                          value = value / 10000000 + "kw";
                      } else if (value >= 1000 && value < 10000) {
                          value = value / 1000 + "k";
                      }
                      return value;
                  }
              },
               splitLine:params.yAxis.splitLine,
            },{
              type: 'value',
              name:moduledatas.label[1],
              max:max1,
              min:0,
              axisLine:params.yAxis.axisLine,
              axisLabel:{
                  show: true,
                  textStyle: {
                    color: params.yAxis.axisLabel.color,  //更改坐标轴文字颜色
                    fontSize : params.yAxis.axisLabel.fontSize     //更改坐标轴文字大小
                  },
                  formatter: function (value, index) {
                      if (value >= 10000 && value < 10000000) {
                          value = value / 10000 + "w";
                      } else if (value >= 10000000) {
                          value = value / 10000000 + "kw";
                      } else if (value >= 1000 && value < 10000) {
                          value = value / 1000 + "k";
                      }
                      return value;
                  }
              },
               splitLine:params.yAxis.splitLine,
            }],
          series: series //series_end
        }
        return data;
  },
}